<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>demo</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <!--<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />-->
    <link rel="stylesheet" href="../../css/font.css">
    <link rel="stylesheet" href="../../css/xadmin.css">
    <link rel="stylesheet" href="../../lib/layui/css/layui.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="../../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../../js/xadmin.js"></script>
    <script type="text/javascript" src="../../js/cookie.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a>
          <cite>订单列表</cite>
        </a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="demoTable">
    <!--<div class="layui-input-inline">-->
    <!--<select id="classify">-->
    <!--<option value="">请选择单号类型</option>-->
    <!--<option value="sys_no">系统订单号</option>-->
    <!--<option value="goods_no">货物订单号</option>-->
    <!--</select>-->
    <!--</div>-->
    <div class="layui-inline">
        <input type="text" id="field" name="field" placeholder="请输入订单号" autocomplete="off" class="layui-input">
    </div>
    <!--<div class="layui-input-inline">-->
    <!--<select id="status">-->
    <!--&lt;!&ndash;<option value="">订单状态</option>&ndash;&gt;-->
    <!--<option value="">全部状态</option>-->
    <!--<option value="0">开始配送</option>-->
    <!--<option value="1">中转</option>-->
    <!--<option value="2">签收</option>-->
    <!--<option value="3">寄存签收</option>-->
    <!--<option value="4">拒收</option>-->
    <!--<option value="5">收到退货</option>-->
    <!--</select>-->
    <!--</div>-->
    <button id="sreach" class="layui-btn" data-type="reload" lay-filter="sreach">搜索</button>
</div>
<table class="layui-hide" id="test" lay-filter="test"></table>
<script type="text/html" id="barDemo">
    <a lay-event="edit" onclick="x_admin_show('订单详情','order-xiangqing.html')" href="javascript:;">订单详情</a>
</script>

<!--订单列表拿到数据-->
<script>
    layui.use('table', function () {
        var table = layui.table;
        table.render({
            elem: '#test'
            , url: '/servletDemo?func=ddlist'
            , cols: [[
                {field: 'sys_no', width: 150, title: '系统订单号'}
                , {field: 'goods_no', width: 150, title: '货物订单号'}
                , {field: 'name', width: 110, title: '收货人姓名'}
                , {field: 'tel', width: 120, title: '收货人联系方式'}
                , {field: 'area', width: 80, title: '所属区域'}
                , {field: 'consignee_address', width: 150, title: '收货人地址'}
                , {
                    field: 'status_number', width: 80, title: '订单状态',
                    templet: function (item) {
                        var s = item.status_number;
                        if (s == 0) {
                            return "开始配送";
                        } else if (s == 1) {
                            return "中转";
                        } else if (s == 2) {
                            return "签收";
                        } else if (s == 3) {
                            return "寄存签收";
                        } else if (s == 4) {
                            return "拒收";
                        } else if (s == 5) {
                            return "收到退货";
                        }
                        return null;
                    }
                }
                , {field: 'created_date', width: 150, title: '下单时间'}
                , {field: 's_name', width: 80, title: '制单人'}
                , {field: 'wealth', width: 100, title: '操作', toolbar: '#barDemo'}
            ]]
            , id: 'reload'
            // ,goods_no: 'goods_noReload'
            , page: true
        });

        var $ = layui.$, active = {
            reload: function () {
                var demoReload = $('#number');

                //执行重载
                tableIns.reload('sys_noReload', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    , where: {
                        key: {
                            sys_no: demoReload.val()
                        }
                    }
                });
            }
        };
        //监听点击搜索
        $('.demoTable .layui-btn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

        //监听行工具时间
        table.on('tool(test)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
            var data = obj.data //获得当前行数据
                , layEvent = obj.event; //获得 lay-event 对应的值
            if (layEvent === 'edit') {
                //console.log(data.sys_no);
                $.ajax({
                    url: '/servletXq?func=login',
                    type: 'get',
                    data: {'ddname': data.sys_no},
                    dataType: 'json',
                    success: function (backData) {
                        console.log(backData)
                        console.log(backData.status)
                    },
                    error: function (e) {
                        console.log(e)
                    }
                });
            } else if (layEvent === 'tuihuo') {
                //console.log(data.sys_no);
                $.ajax({
                    url: '/servletXq?func=login',
                    type: 'get',
                    data: {'ddname': data.sys_no},
                    dataType: 'json',
                    success: function (backData) {
                        console.log(backData)
                        console.log(backData.status)
                    },
                    error: function (e) {
                        console.log(e)
                    }
                });

            }
        });
    });
</script>
<!--查询订单表单返回数据-->
<script>
    $(function () {
        $("#ss").on("click", function () {
            $.ajax({
                url: '/servletDemo',
                type: 'get',
                data: {
                    'username': $("input[name=username]").val(),
                    'number': $("select[name=number]").val(),
                    'contrller': $("select[name=contrller]").val()
                },
                dataType: 'json',
                success: function (backData) {
                    console.log(backData)
                    console.log(backData.status)
                },
                error: function (e) {
                    console.log(e)
                }
            });
        });
    });
</script>
<script>
    layui.use('laydate', function () {
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });
    });
</script>

</body>

</html>